using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UI_SkillSlotManager : MonoBehaviour
{
    public static UI_SkillSlotManager instance;
    [SerializeField] private Image counterAttackCoolDownImage;
    [SerializeField] private Image throwSwordCoolDownImage;
    [SerializeField] private Image dashCoolDownImage;
    [SerializeField] private Image crystalCoolDownImage;
    [SerializeField] private Image ultimateCoolDownImage;


    private void Awake()
    {
        if (instance != null)
        {
            Destroy(instance);
        }
        else
        { 
            instance = this;
        }
    }

    private void Update()
    {

        if (dashCoolDownImage != null)
            UpdateCoolDownUI(dashCoolDownImage, SkillManager.instance.dashSkill);
        if (counterAttackCoolDownImage != null)
            UpdateCoolDownUI(counterAttackCoolDownImage, SkillManager.instance.counterAttackSkill);
        if (crystalCoolDownImage!=null)
            UpdateCoolDownUI(crystalCoolDownImage, SkillManager.instance.crystalSkill);
        if (throwSwordCoolDownImage != null)
            UpdateCoolDownUI(throwSwordCoolDownImage, SkillManager.instance.swordSkill);
        if (ultimateCoolDownImage != null)
            UpdateCoolDownUI(ultimateCoolDownImage,SkillManager.instance.ultimateSkill);
    }

    private void UpdateCoolDownUI(Image cooldownImage,Skill skill)
    { 
        cooldownImage.fillAmount = skill.GetCooldownRate();
    }


}
